package com.visual.core.http;

import org.springframework.http.HttpStatus;

public class ResponseWrapper<T> {

    private int code;

    private String msg;

    private boolean success;

    private T data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;

        if(success){
            this.setCode(HttpStatus.OK.value());
            this.setMsg("操作成功");
        }else{
            this.setCode(HttpStatus.BAD_REQUEST.value());
            this.setMsg("操作失败");
        }

    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
